package com.thinkgem.jeesite.modules.spider.utils;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

public class RedisHelper {
	private Jedis jedis;
	private JedisPool jedisPool;

	public RedisHelper() {
		initialPool();
		jedis = jedisPool.getResource();
	}

	private void initialPool() {
		// 池基本配置
		JedisPoolConfig config = new JedisPoolConfig();
		//config.setMaxActive(500);
		config.setMaxIdle(20);
		//config.setMaxWait(10000l);
		config.setTestOnBorrow(true);
		config.setTestOnReturn(true);

		jedisPool = new JedisPool(config, "101.200.90.93", 6379);
	}

	public Jedis getJedis() {
		return jedis;
	}

	public void setJedis(Jedis jedis) {
		this.jedis = jedis;
	}

	public JedisPool getJedisPool() {
		return jedisPool;
	}

	public void setJedisPool(JedisPool jedisPool) {
		this.jedisPool = jedisPool;
	}
}
